//
//  LGTeamManagerCell.m
//  BreathTrainingTool
//
//  Created by 1234 on 2024/7/11.
//  团队列表Cell

#import "LGTeamManagerCell.h"

@interface LGTeamManagerCell()
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *numberLabel;
/**   */
@property (nonatomic , strong)UIImageView *tipView;

@end

@implementation LGTeamManagerCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.type = LGPositionTypeSingle;
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    [super setDataDic:dataDic];
    self.titleLabel.text = LGNSString(dataDic[@"name"]);
    self.numberLabel.text = [NSString stringWithFormat:@"当前成员%ld个",[dataDic[@"users"] count]];
    self.tipButton.selected = [dataDic[@"manager"] integerValue]>0?YES:NO;
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.baseView addSubview:self.titleLabel];
    [self.baseView addSubview:self.tipButton];
    [self.baseView addSubview:self.numberLabel];
    [self.baseView addSubview:self.tipView];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.baseView).offset(viewPix(14));
        make.left.equalTo(self.baseView).offset(viewPix(16));
    }];
    [self.tipButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_right).offset(viewPix(10));
        make.right.lessThanOrEqualTo(self.baseView).offset(-viewPix(35));
        make.centerY.equalTo(self.titleLabel);
        make.width.equalTo(@(viewPix(70)));
        make.height.equalTo(@(viewPix(22)));
    }];
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(viewPix(8));
        make.left.equalTo(self.titleLabel);
        make.bottom.equalTo(self.baseView).offset(-viewPix(14));
    }];
    [self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.baseView).offset(-viewPix(16));
        make.centerY.equalTo(self.baseView);
        make.width.height.equalTo(@(viewPix(16)));
    }];
}


-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#2B2A37" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _titleLabel;
}

-(UIButton *)tipButton{
    if(!_tipButton){
        _tipButton = [UIButton buttonWithTitle:@"我加入的" titleFont:LGFont(14) normalColor:kThemeColor selectColor:@"#FFFFFF"];
        [_tipButton addBorder:kThemeColor lineWidth:1 cornerRidus:viewPix(11)];
        [_tipButton setBackgroundColor:@"#FFFFFF" selectColor:kThemeColor];
        [_tipButton setTitle:@"我的团队" forState:UIControlStateSelected];
        _tipButton.userInteractionEnabled = NO;
        _tipButton.cornerRidus = viewPix(11);
    }
    return _tipButton;
}

-(UILabel *)numberLabel{
    if(!_numberLabel){
        _numberLabel = [UILabel lableWithText:@"" colorString:@"#968F8F" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _numberLabel;
}

-(UIImageView *)tipView{
    if(!_tipView){
        _tipView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"grayTip16"]];
    }
    return _tipView;
}

@end
